<template>
  <div class='search'>
    <f-form ref='form' :action='api.spd' :form-key='this.formItem.designerId'>
      <f-form-item label='模板编码' name='designerCode' required :value='formItem.designerCode' />
      <f-form-item label='模板标题' name='designerTitle' required :value='formItem.designerTitle' />
    </f-form>
  </div>
</template>
<script>
import api from "./js/api"

export default {
  name: "spdForm",
  props: {},
  data() {
    return {
      refs: this.$refs,
      api: Object.assign(api, this.api),
      isAdd: true,//是否是添加模式
      loaded: false,//是否加载完成
      formItem: this.getFormItem()
    }
  },
  methods: {
    getFormItem() {
      return {
        designerId: "",
        designerCode: "",
        designerTitle: "",
        designerContent: "",
        designerState: "",
        companyId: "",
        createTime: "",
        updateTime: ""
      }
    },
    //表单赋值
    setData(data) {
      this.$refs.form.resetFields()
      this.formItem = this.getFormItem()
      if (data && data.designerId) {
        let params = {
          designerId: data.designerId
        }
        this.refs["form"].getDetails(params, (data) => {
          this.formItem = data
          this.loaded = true
        })
        this.isAdd = false
      } else {
        this.loaded = true
      }
    },
    //提交表单
    handleSubmit(callback) {
      this.$refs.form.submit({}, callback)
    }
  },
  created() {
  },
  components: {}
}
</script>

<style scoped lang='less' rel='stylesheet/less'>

</style>
